//
//  UIBarButtonItem+Extensions.swift
//  sinaWebo
//
//  Created by sinaFenQi on 2017/12/7.
//  Copyright © 2017年 sinaFenQi. All rights reserved.
//

import UIKit
extension UIBarButtonItem{
    
    /// 创建UIBarButtonItem
    ///
    /// - Parameters:
    ///   - title: 名字
    ///   - fontSize: 字体大小
    ///   - target: 代理
    ///   - action: 方法
    convenience init(title: String , fontSize:CGFloat = 16 , target:AnyObject , action:Selector, isBack: Bool = false) {
    
        let barBut:UIButton = UIButton.cz_textButton(title, fontSize:fontSize, normalColor: UIColor.darkGray, highlightedColor: UIColor.orange)
        
        if isBack {
            let ImageName = "navigationbar_back_withtext"
            barBut.setImage(UIImage(named:ImageName), for: .normal)
            barBut.setImage(UIImage(named:ImageName + "_highlighted"), for: .highlighted)
            
            barBut.sizeToFit()
        }
        
        barBut.addTarget(target, action: action, for: .touchUpInside)
        
        self.init(customView: barBut)
    }
    
    
}
